//
//  HotNewsCollectionViewCell.swift
//  koolcar
//
//  Created by kuaimaxiansheng on 2023/9/19.
//

import UIKit
import FSPagerView
class HotNewsCollectionViewCell: FSPagerViewCell {

    var hotImageView: UIImageView!
    var bottomView: UIView!
    var titleLab: UILabel!
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = .clear
        self.clipsToBounds = true
        self.contentView.layer.shadowColor = UIColor.clear.cgColor
        self.contentView.layer.shadowRadius = 0
        self.contentView.layer.shadowOpacity = 0
        self.contentView.layer.shadowOffset = .zero
        self.initUI()
    }
    
    func initUI(){
        
        self.hotImageView = UIImageView(frame: CGRect(x: 0, y: 0, width: self.frame.size.width, height: 195))
        self.hotImageView.isUserInteractionEnabled = true
        self.hotImageView.layer.cornerRadius = 8
        self.hotImageView.clipsToBounds = true
        self.hotImageView.backgroundColor = .clear
        self.hotImageView.contentMode = .scaleAspectFill
        self.contentView.addSubview(self.hotImageView)
        
        
        self.bottomView = UIView(frame: CGRect(x: 0, y: self.frame.size.height - 60, width: self.frame.size.width, height: 60))
        self.bottomView.backgroundColor = UIColor(hex: 0x030303,alpha:0.5)
        self.hotImageView.addSubview(self.bottomView)
    
        self.titleLab = UILabel(frame: CGRect(x: 14, y: 0, width: self.frame.size.width - 28, height: 60))
        self.titleLab.textColor = .white
        self.titleLab.font = UIFont.init(name: Theme.PingFangSCMedium, size: 14)
        self.titleLab.numberOfLines = 2
        self.bottomView.addSubview(self.titleLab)
        
        self.hotImageView.snp.makeConstraints { make in
            make.top.equalTo(0)
            make.left.equalTo(0)
            make.right.equalTo(0)
            make.height.equalTo(195)
        }
        
    }
    
    //setModel
    func setModel(model: HotNewsDataModel){
        self.hotImageView?.sd_setImage(with: URL.init(string: model.imageUrl ?? ""))
        self.titleLab.text = model.title ?? ""
    }
    
    
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
